package com.simonall.netty;

import com.simonall.netty.handler.SimpleHttpRequestHandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * 声明：流水线
 * 
 * @author simonall
 */
public class Initializer extends ChannelInitializer<NioSocketChannel> {

	@Override
	protected void initChannel(NioSocketChannel ch) throws Exception {
		ChannelPipeline pipeline = ch.pipeline();
		pipeline.addLast(new HttpServerCodec());
		pipeline.addLast(new HttpObjectAggregator(8 * 1024 * 1024)); // 8M
		pipeline.addLast(new SimpleHttpRequestHandler());
	}

}
